package com.wcity.manage.common.utils;

import java.io.IOException;
import java.io.InputStream;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;

/**
 * propertie工具
 *
 * @author dy
 */
public class PropertieUtil {

	/**
	 * 加载propertie到Map
	 *
	 * @param is
	 * @return
	 * @throws java.io.IOException
	 */
	public static Map<String, String> loadToMap( InputStream is ) throws IOException {
		Properties props = new Properties();
		props.load( is );
		Map<String, String> map = new HashMap<String, String>();
		Enumeration<?> en = props.propertyNames();
		while ( en.hasMoreElements() ) {
			String key = (String) en.nextElement();
			if ( null != key ) {
				String val = props.getProperty( key );
				if (val != null) map.put( key, val );
			}
		}
		return map;
	}

}
